//
//  WaitViewController.m
//  FruitVIP
//
//  Created by 孙艳玲 on 15/5/25.
//  Copyright (c) 2015年 孙艳玲. All rights reserved.
//

#import "WaitViewController.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@interface WaitViewController ()

@end

@implementation WaitViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = [UIColor brownColor];
    
    
     self.cellArray = [NSMutableArray arrayWithArray:@[@"detailone.jpg",@"detailtwo.jpg", @"detailthree.jpg", @"detailfour.jpg", @"detailfive.jpg", @"detailsix.jpg"]];
    
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES ;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    
    self.navigationItem.title = @"代发货订单";
    self.navigationController.navigationBar.hidden = NO;
    
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:110.0 / 255.0 green:78.0 / 255.0 blue:71.0 / 255.0 alpha:1]}];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255.0/255.0 green:205.0 / 255.0 blue:0 / 255.0 alpha:1];
    
    
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.myTableView.backgroundColor = [UIColor whiteColor];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    //取消分割线
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.myTableView];
    
    UIImageView *backImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    UIImage *image = [UIImage imageNamed:@"back.png"];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    backImage.contentMode = UIViewContentModeScaleAspectFit;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 5, 10, 20);
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button addTarget:self action:@selector(leftButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [backImage addSubview:button];
    UITapGestureRecognizer *backTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftButtonAction)];
    [backImage addGestureRecognizer:backTap];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backImage];
}

- (void)leftButtonAction
{
    [self.navigationController popViewControllerAnimated:YES];


}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
    return self.cellArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
    static NSString *cellIdentifier = @"cell";
    WaitTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[WaitTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSString *str = [self.cellArray objectAtIndex:indexPath.row];
    cell.waitImageView.image = [UIImage imageNamed:str];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (SCREEN_WIDTH == 320 && SCREEN_HEIGHT == 480) {
        return SCREEN_HEIGHT/3.9;
    }
    return SCREEN_HEIGHT / 4.5;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailViewController *detailVC = [[DetailViewController alloc] init];
    [self.navigationController pushViewController:detailVC animated:YES];
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
